//
//  LemonMixView.m
//  Jyxt
//
//  Created by 刘日 on 17/5/17.
//  Copyright © 2017年 DaLian Rental Housing Management. All rights reserved.
//

#import "LemonMixView.h"

@interface LemonMixView()

@property (nonatomic , strong) WKWebView *lmWebView;

@end

@implementation LemonMixView

- (instancetype)init{
    if (self = [super init]) {
        [self _initAll];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame: frame]) {
        [self _initAll];
    }
    return self;
}

- (Communication *)comInterface{
    if (!_comInterface) {
        _comInterface = [[Communication alloc] initWithMixView: self webView: _lmWebView];
    }
    return _comInterface;
}

- (OperateExten *)operate{
    if (!_operate) {
        _operate = [[OperateExten alloc] initWithMixView: self webView: _lmWebView];
    }
    return _operate;
}

- (OnExten *)on{
    if (!_on) {
        _on = [[OnExten alloc] initWithMixView: self webView: _lmWebView];
    }
    return _on;
}

- (DataExten *)data{
    if (!_data) {
        _data = [[DataExten alloc] initWithMixView: self webView: _lmWebView];
    }
    return _data;
}

- (void)_initAll{
    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    self.lmWebView = [[WKWebView alloc] initWithFrame: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) configuration:config];
    [self addSubview: self.lmWebView];
    self.lmWebView.UIDelegate = self.comInterface;
}

- (void)setFrame:(CGRect)frame{
    [super setFrame:frame];
    self.lmWebView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
}

@end
